/*
*	this css file was created jaypha
*	jaypha information:
*	name:jaypha
*	email:psufool@163.com
*	qq:psufool@qq.com
*	homePage:http://www.psufool.cn/
*/
document.charset = "utf-8";

var chkBrowers = function(){	
	if($.browser.msie){
		if($.browser.version<=7.0){
			var strTitle = '重要提示';
			var strHtml = '<p class="mess-detail" style="padding:5px 0 0 2px; text-align:center; line-height:28px;">对不起，目前版本暂不支持IE7及以下浏览器。<br />感谢您使用<a href="http://www.psufool.cn" title="内容管理系统" target="_blank" style="color:#f00; margin:0 5px;">内容管理系统</a>！</p>';
			var alertMess = new J.ui.dialog({
				id:'alertMess',
				width:300,
				height:100,
				cover:true,
				resize:false,
				drag:false,
				title:strTitle,
				html:strHtml,
				btns:false,
				cusfn:function(){
					J('#xbtn',alertMess.dlg).remove();
						alertMess.addBtn('close','关 闭',function(){
							alertMess.cancel();
					});
				}
			});
			alertMess.ShowDialog();
			return false;
		}else{
			return true;
		}
	}else{
		return true;
	}
}

/*JS调用flash*/
var EmbedStr = "";
function GetFlash(url,x,y) { 
	EmbedStr = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='" + x + "' height='" + y + "'>";
	EmbedStr += "<param name='allowScriptAccess' value='always' />";
	EmbedStr += "<param name='movie' value='" + url + "' />";
	EmbedStr += "<param name='quality' value='high' />";
	EmbedStr += "<param name='wmode' value='transparent' />";
	EmbedStr += "<param name='menu' value='false' />";
	EmbedStr += "<embed src='" + url + "' id='flashObject' name='flashObject' quality='high' menu='false' wmode='transparent' bgcolor='#ffffff' width='" + x + "' height='" + y + "' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
	EmbedStr += "</object>";	
	document.write(EmbedStr);
	return;
}
/*
页面跳转
url:跳转页面
targetStr:跳转方式(_self,_blank,_parent,_top)
*/
function gotoLocation(url,targetStr){
	var tempUrl=url.toLowerCase();
	if(targetStr.length==0){
		targetStr="_self";
	}
	targetStr = targetStr.toLowerCase();
	targetStr=targetStr.toLowerCase();
	if(targetStr=="_self"){
		if(tempUrl.indexOf("history.")>=0 || tempUrl.indexOf("window.location.reload()")>=0){
			url;
		}else{
			this.location.href=url;
		}
	}else{
		window.open(url,targetStr);	
	}
}
/*
弹出消息对话框
messStr:弹出信息内容
url:跳转页面
targetStr:跳转方式(_self,_blank,_parent,_top)
*/
function messDailog(messStr,url,targetStr){
	alert(messStr);
	var tempUrl=url.toLowerCase();
	if(tempUrl.indexOf("history.")>=0){
		history.back();
	}else if(tempUrl.indexOf("window.location.reload()")>=0){
		window.location.reload();
	}else{
		gotoLocation(url,targetStr);
	}
}
/*
创建XMLHttpRequest对象
支持火狐
*/
function createXmlHttp(){ 
	var objXmlHttp=null; 
	try{ 
		objXmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e){ 
    	try{ 
        	objXmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      	} 
        catch(oc){
			objXmlHttp=new XMLHttpRequest();	//火狐下的创建方式
		} 
	}
	return objXmlHttp; 
}  
/*
异步打开页面
URL	要打开的页面
openMethod 打开方式（POST/GET）
*/
function openURL(URL,openMethod){
	objXML=createXmlHttp();
	objXML.open(openMethod,URL,false);
	objXML.send(null);	//null为必须,如果没有则在火狐下失效
	returnValue=objXML.responseText;
	objXML.onreadystatechange=openURL;
	if(objXML.readyState==4){
		if(objXML.status==200){
			return returnValue;
		}
		else{
			return "errorMessage";
		}
	}else{
		alert(objXML.status);	
	}
	objXML.close;
}

/*加入收藏夹*/
function addFavorite(sURL,sTitle){
    try{
        window.external.addFavorite(sURL, sTitle);
    }catch (e){
        try{
            window.sidebar.addPanel(sTitle, sURL, "");
        }catch(e){
            alert("加入收藏失败，请使用Ctrl+D进行添加");
        }
    }
}
/*设为主页*/
function setHome(obj,vrl){
	try{
		obj.style.behavior='url(#default#homepage)';
		obj.setHomePage(vrl);
	}catch(e){
		if(window.netscape){
			try {
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
			}catch(e){
				alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'");  
			}
			var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
			prefs.setCharPref('browser.startup.homepage',vrl);
		}
	}
}
/*判断是否为IE*/
function isIE(){ //ie? 
if (window.navigator.userAgent.toLowerCase().indexOf("msie")>=1) 
    return true; 
else 
    return false; 
}
/*判断是否为数字*/
function isNumber(oNum){ 
	if(!oNum) return false; 
	var strP=/^(\d+)?(\.\d+)?$/; 
	if(!strP.test(oNum)) return false; 
	try{ 
		if(parseFloat(oNum)!=oNum) return false; 
	}catch(ex){ 
		return false; 
	} 
	return true; 
}

/*判断是否为email*/
function isEmail(emailStr){
	if(emailStr.charAt(0) == "." || emailStr.charAt(0) == "@" || emailStr.indexOf('@', 0) == -1|| emailStr.indexOf('.', 0) == -1 || emailStr.lastIndexOf("@") == emailStr.length-1 || emailStr.lastIndexOf(".") == emailStr.length-1){
		return false;	
	}else{
		return true;
	}
}

/*判断是否为顶层框架*/
function isTop(){
	if(self==top){
		window.top.location.href="/admin/index";
		return false;
	}
}

function drawImage(ImgD,FitWidth,FitHeight){     
	var image=new Image();     
	image.src=ImgD.src;     
	if(image.width>0 && image.height>0){
		if(image.width/image.height>= FitWidth/FitHeight){
			if(image.width>FitWidth){
				ImgD.width=FitWidth;
				ImgD.height=(image.height*FitWidth)/image.width;
			}else{
				ImgD.width=image.width;
				ImgD.height=image.height;
			}
		}else{
			if(image.height>FitHeight){
				ImgD.height=FitHeight;                 
				ImgD.width=(image.width*FitHeight)/image.height; 
			}else{                 
				ImgD.width=image.width;
				ImgD.height=image.height; 
			}
		}
	}
}

/*
*作用：分页显示
*参数：pageListId：分页的ID
*参数：pageTotal：总页数
*参数：num_prev_next：
*参数：num_display：一个页面显示分页数量
*参数：selectPageFunction：选择页面后执行的方法
*/
function jqPageList(pageListId,pageTotal,num_prev_next,num_display,selectPageFunction){
	$("#"+pageListId+"").pagination(pageTotal,{
		num_edge_entries:num_prev_next,
		num_display_entries:num_display,
		callback: selectPageFunction
	});
}

function goPageList(pageNum,formStr){
	var objForm = $("form[name='" + formStr + "Form']");
	objForm.find("#page").val(pageNum);
	objForm.submit();
}

function parentFolder(formStr){
	var oP = $("#" + formStr + "Form .prevFolder a");
	oP.click(function(){
		var objForm = $("#"+formStr+"Form");
		objForm.find("#active").val("viewFolder");
	//objForm.active.value="viewFolder";
		objForm.submit();
		return false;
	});
}

function subFolder(formStr){
	var oFA = $("#" + formStr + "Form .folder a");
	oFA.click(function(){
		var objForm = $("#"+formStr+"Form");
		var v=null;
		v = $(this).parent().siblings().find("input").val();
		objForm.find("#goFolder").val(v);
		objForm.submit();
		return false;
	});
}

function viewFile(formStr){
	var objForm = $("#" + formStr + "Form");
	objForm.find(".fileLink").click(function(){
		window.open($(this).parent().siblings().eq(0).children().val(),"_blank","toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no");
		return false;
	});	
}

function allClick(formStr){
	var obj = $("#" + formStr + "Form");
	obj.find("#all").click(function(){
		if($(this).attr("checked")){
			obj.find("input[type='checkbox'][name='folder']").attr("checked","checked");
			obj.find("input[type='checkbox'][name='file']").attr("checked","checked");
		}else{
			obj.find("input[type='checkbox'][name='folder']").removeAttr("checked");
			obj.find("input[type='checkbox'][name='file']").removeAttr("checked");
		}
	});
}

function filterHTML(str){
	str = str.replace(/<\/?[^>]+>/g,''); //去除HTML tag
	str = str.replace(/[ | ]*\n/g,'\n'); //去除行尾空白
	str = str.replace(/\n[\s| | ]*\r/g,'\n'); //去除多余空行
	return str;
}

/*生成上传进程ID*/
var getProcessId=function (){
    var mydt=new Date();
    with(mydt){
        var y=getYear();if(y<10){y='0'+y}
        var m=getMonth()+1;if(m<10){m='0'+m}
        var d=getDate();if(d<10){d='0'+d}
        var h=getHours();if(h<10){h='0'+h}
        var mm=getMinutes();if(mm<10){mm='0'+mm}
        var s=getSeconds();if(s<10){s='0'+s}
    }
    var r="000" + Math.floor(Math.random() * 1000);
    r=r.substr(r.length-4);
    return y + m + d + h + mm + s + r;
};